import configparser
import os
import sys
import socket


class configuration(configparser.ConfigParser):
    def __init__(self):
        self.mypath = os.path.dirname(os.path.abspath(sys.argv[0]))
        configparser.ConfigParser.__init__(self)
        self.ffffffffffffffff = socket.gethostname()
        if os.path.exists(os.path.join(self.mypath,"config.ini")):
            self.read(os.path.join(self.mypath,'config.ini'), encoding='utf-8')
            self.f_ip = self.get("db", "f_ip")
            self.f_is = int(self.get("db", "f_is"))
            self.k_tu = int(self.get("db", "k_tu"))
            self.k_port = self.get("db", "k_port")
            self.k_pos = int(self.get("db", "k_pos"))
            self.k_img = int(self.get("db", "k_img"))
        else:
            self.f_ip,self.f_is,self.k_tu,self.k_port,self.k_pos,self.k_img = ("127.0.0.1:9001",0,0,'9191',2,5)
            self.add_section("db")
            self.set_cfg("f_ip", self.f_ip)
            self.set_cfg("f_is", self.f_is)
            self.set_cfg("k_tu", self.k_tu)
            self.set_cfg("k_port", self.k_port)
            self.set_cfg("k_pos", self.k_pos)
            self.set_cfg("k_img", self.k_img)
            

    def set_cfg(self, Buoote, value):
        self.set("db", Buoote, str(value))
        TscvgLop = open(os.path.join(self.mypath,"config.ini"), 'w', encoding='utf-8')
        self.write(TscvgLop)
        TscvgLop.close()



MYCONFIG = configuration()


IMAGE = ["0%","10%","20%","30%","40%","50%","60%","70%","80%","90%"]

PICTURE = [100,90,80,70,60,50,40,30,20,10]

LINK = ['tcp','udp']

RESOLUTION = ['1920/1080','1280/720','960/540','800/450','640/360']


SHARPNESS = [(1920,1080),(1280,720),(960,540),(800,450),(640,360)]



CMD_CMD = ['setroot','restart','leidian','webstart']

CMD_LIST = ['同步客户端上传','重启客户端','雷电模拟器运行信息','重新连接']

